import axios from '@/utils/request';

/**
 * 新增客户信息
 * @params 客户信息
 */
export async function AddCustomer(params) {
    const res = await axios.post('/Customer/AddCustomer', params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 修改客户信息
 * @params 客户信息
 */
export async function UpdateCustomer(params) {
    const res = await axios.post('/Customer/UpdateCustomer', params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 查询客户信息
 * @params 客户信息
 */
export async function QueryCustomerByCondition(params) {
    const res = await axios.post('/Customer/QueryCustomerByCondition', params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 根据客户Id查询客户信息
 * @params 客户Id
 */
export async function QueryCustomerById(id) {
    console.log(id);
    const res = await axios.get('/CustomerWebChart/QueryWebChartCustomerById?id=' + id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据客户Id删除客户信息
 * @params 客户Id
 */
export async function Delete(id) {
    const res = await axios.get('/CustomerWebChart/DeleteCustomer/' + id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 查询客户设备信息
 * @params 客户设备信息
 */
export async function QueryCustomerDeviceByCondition(params) {
    const res = await axios.post('/CustomerDevice/QueryCustomerDeviceByCondition', params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

